//读取,国家地区数组
var state = new Array();
$.ajax({
	url: "https://www.easy-mock.com/mock/5a6e8476376cc81223703e9d/test",
	type: "get",
	dataType: "json",
	success: function (s) {
		console.log(s);
		//赋值国家
		state[0] = s.data.state.Global;
		state[1] = s.data.state.China;
		state[2] = s.data.state.HongKong;
		state[3] = s.data.state.Taiwan;
		state[4] = s.data.state.Macau;
		state[5] = s.data.state.Korea;
		state[6] = s.data.state.Malaysia;
		state[7] = s.data.state.Australia;
		state[8] = s.data.state.Singapore;
		state[9] = s.data.state.New_Zealand;
		state[10] = s.data.state.Canada;
		state[11] = s.data.state.America;
		state[12] = s.data.state.Japan;
		//print with element
		$("#global").text(state[0]);
		document.getElementById("china").innerText = state[1];
		$("#hongkong").text(state[2]);
		$("#taiwan").text(state[3]);
		$("#macau").text(state[4]);
		$("#korea").text(state[5]);
		$("#malaysia").text(state[6]);
		document.getElementById("australia").innerText = state[7];
		document.getElementById("singapore").innerText = state[8];
		document.getElementById("new-zealand").innerText = state[9];
		document.getElementById("canada").innerText = state[10];
		document.getElementById("america").innerText = state[11];
		document.getElementById("japan").innerText = state[12];
	},
	fail: function (f) {
		console.log("Fail");
	}
});
// 监听state区域 并且不让他上传倒父类
document.querySelector("#state").addEventListener("click",function(event){
	// /do you have state-click class
	// if ($("#state").hasClass("state-click")) {
	// 	//remove
	// 	$("#state").removeClass("state-click");
	// 	$("#triangle-arrows").removeClass("triangle-arrows-rotate");
	// }else{
	// 	//add
	// 	$("#state").addClass("state-click");
	// 	$("#triangle-arrows").addClass("triangle-arrows-rotate");
	// }
	$("#state").toggleClass("state-click");
	$("#triangle-arrows").toggleClass("triangle-arrows-rotate");
	$("#state-location-list").slideToggle();
	event.stopPropagation();//不让他上传倒父类
},false);
//点击任何地方 地区列表都会被上卷
document.addEventListener('click', function(){
	$("#triangle-arrows").removeClass("triangle-arrows-rotate");
	$("#state").removeClass("state-click");
	$("#state-location-list").slideUp();
}, false);

//单击一个list内容时读取内容覆盖国家默认值(中国大陆)
$("#global").click(function(){
	console.log("global 被单机");
	$("#triangle-arrows").removeClass("triangle-arrows-rotate");
	$("#state").removeClass("state-click");
	$("#state-values").text("全国");
	$("#state-location-list").slideUp();
	event.stopPropagation();//不让他上传倒父类
});
$("#china").click(function(){
	console.log("china 被单机");
	$("#triangle-arrows").removeClass("triangle-arrows-rotate");
	$("#state").removeClass("state-click");
	$("#state-values").text("中国大陆");
	$("#state-location-list").slideUp();
	event.stopPropagation();//不让他上传倒父类
});
$("#hongkong").click(function(){
	console.log("hongkong 被单机");
	$("#triangle-arrows").removeClass("triangle-arrows-rotate");
	$("#state").removeClass("state-click");
	$("#state-values").text("香港");
	$("#state-location-list").slideUp();
	event.stopPropagation();//不让他上传倒父类
});
$("#taiwan").click(function(){
	console.log("taiwan 被单机");
	$("#triangle-arrows").removeClass("triangle-arrows-rotate");
	$("#state").removeClass("state-click");
	$("#state-values").text("台湾");
	$("#state-location-list").slideUp();
	event.stopPropagation();//不让他上传倒父类
});
$("#macau").click(function(){
	console.log("macau 被单机");
	$("#triangle-arrows").removeClass("triangle-arrows-rotate");
	$("#state").removeClass("state-click");
	$("#state-values").text("香港");
	$("#state-location-list").slideUp();
	event.stopPropagation();//不让他上传倒父类
});
$("#korea").click(function(){
	console.log("korea 被单机");
	$("#triangle-arrows").removeClass("triangle-arrows-rotate");
	$("#state").removeClass("state-click");
	$("#state-values").text("韩国");
	$("#state-location-list").slideUp();
	event.stopPropagation();//不让他上传倒父类
});
$("#malaysia").click(function(){
	console.log("malaysia 被单机");
	$("#triangle-arrows").removeClass("triangle-arrows-rotate");
	$("#state").removeClass("state-click");
	$("#state-values").text("马来西亚");
	$("#state-location-list").slideUp();
	event.stopPropagation();//不让他上传倒父类
});
document.getElementById("australia").onclick=function(){
	console.log("australia 被单机");
	$("#triangle-arrows").removeClass("triangle-arrows-rotate");
	$("#state").removeClass("state-click");
	document.getElementById("state-values").innerText="澳大利亚";
	$("#state-location-list").slideUp();
	event.stopPropagation();//不让他上传倒父类
};
document.getElementById("singapore").onclick=function(){
	console.log("singapore 被单机");
	$("#triangle-arrows").removeClass("triangle-arrows-rotate");
	$("#state").removeClass("state-click");
	document.getElementById("state-values").innerText="新加坡";
	$("#state-location-list").slideUp();
	event.stopPropagation();//不让他上传倒父类
};
document.getElementById("new-zealand").onclick=function(){
	console.log("new-zealand 被单机");
	$("#triangle-arrows").removeClass("triangle-arrows-rotate");
	$("#state").removeClass("state-click");
	document.getElementById("state-values").innerText="新西兰";
	$("#state-location-list").slideUp();
	event.stopPropagation();//不让他上传倒父类
};
document.getElementById("canada").onclick=function(){
	console.log("canada 被单机");
	$("#triangle-arrows").removeClass("triangle-arrows-rotate");
	$("#state").removeClass("state-click");
	document.getElementById("state-values").innerText="加拿大";
	$("#state-location-list").slideUp();
	event.stopPropagation();//不让他上传倒父类
};
document.getElementById("america").onclick=function(){
	console.log("america 被单机");
	$("#triangle-arrows").removeClass("triangle-arrows-rotate");
	$("#state").removeClass("state-click");
	document.getElementById("state-values").innerText="美国";
	$("#state-location-list").slideUp();
	event.stopPropagation();//不让他上传倒父类
};
document.getElementById("japan").onclick=function(){
	console.log("japan 被单机");
	$("#triangle-arrows").removeClass("triangle-arrows-rotate");
	$("#state").removeClass("state-click");
	document.getElementById("state-values").innerText="日本";
	$("#state-location-list").slideUp();
	event.stopPropagation();//不让他上传倒父类
};



